package com.atguigu.common.exception;

import com.atguigu.common.result.ResponseEnum;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class BusinessException extends RuntimeException {
    private Integer code; //异常状态码
    private String message; //异常信息
    /*
    * 错误信息
    * */
    public BusinessException(String message){
        this.message = message;
    }
    /*
    * code 状态码 message 错误信息*/
    public BusinessException(Integer code ,String message){
        this.message = message;
        this.code = code;
    }
    /*
    * resultCodeEnum 接收枚举类型*/
    public BusinessException(ResponseEnum resultCodeEnum){
        this.message = resultCodeEnum.getMessage();
        this.code = resultCodeEnum.getCode();
    }
    /*
    * resultCodeEnum 枚举类型
    * cause 原始异常对象*/
    public BusinessException(ResponseEnum resultCodeEnum,Throwable cause){
        super(cause);
        this.message = resultCodeEnum.getMessage();
        this.code = resultCodeEnum.getCode();
    }
}
